BindsearChangeOnckike()
//监听滚轮事件实现nav置顶
addEventListenerNav(54)
//绑定返回顶端
BindgoTop()
//绑定登录跳转按钮
BindGoLogin()
//绑定图片放大功能效果
BindBlowupImg()
//绑定移动到文章上样式改变
BindBlowupArt()
//前往博客界面
BindgoWirBlog()
//绑定修改用户信息
BindUpUser()

/**
 * 绑定前往写博客界面
 */
function BindgoWirBlog() {
    document.querySelector('#goWirBlog').onclick = function () {
        document.querySelector('#index_wirBlog_box').style.display = '';
        document.querySelector('#index_top_box').style.display = 'none';
        document.querySelector('#index_content_box').style.display = 'none';
        document.querySelector('#index_details_box').style.display = 'none';
    }
}

/**
 * 绑定前往修改用户信息
 * @constructor
 */
function BindUpUser() {
    document.querySelector('#index_top_user_img').onclick = function () {
        document.querySelector('#upUserData_box').style.display = "";
        document.querySelector('#index_top_box').style.display = "none";
        document.querySelector('#index_content_box').style.display = "none";
        document.querySelector('#index_details_box').style.display = "none";

    }
}
document.querySelector('#myzhong').onclick =()=>{
  window.location.href = "../../../HomeIndex.html"
}
document.querySelector('#home').onclick =()=>{
  window.location.href = "../../NewPage/html/New_index.html"
}

/**
 * 绑定进入文章详情功能
 * @param obj
 */
function goDetails(obj) {
    console.log(obj.getAttribute('article_id'))
    GoDetail(obj.getAttribute('article_id'))
    document.querySelector('#index_details_box').style.display = ""
    document.querySelector('#index_top_box').style.display = "none"
    document.querySelector('#index_content_box').style.display = "none"
    // add_hits()

}

/**
 * 每次进来加一次点击量
 */

/*
function add_hits() {
    future.ajax({
        url:'/article/addHist',
        type:'post',
        data:{
            article_id
        },
        success:function (result) {
            console.log(result)
        }
    })

}
*/


function BindBlowupArt() {
    let index_content_left_ul = document.querySelector("#index_content_left_ul").children
    for (let i = 0; i < index_content_left_ul.length; i++) {
        index_content_left_ul[i].onmouseover = function () {
            this.style.border = "1px solid #969896"


        }
        index_content_left_ul[i].onmouseout = function () {
            this.style.border = "none"
        }
    }

}


/**
 * 绑定图片放大函数
 * @constructor
 */
function BindBlowupImg() {
    let left_li_img = document.querySelectorAll('.left_li_img_x')
    left_li_img.forEach((item, index) => {
        item.onmouseover = function () {
            this.style.width = "115%"
            this.style.transition = "width 0.8s"

        }
        item.onmouseout = function () {
            this.style.width = "100%"
            this.style.height = "100%"
            this.style.transition = "width 0.8s"
        }
    })

}

/**
 * 绑定登录跳转按钮实现函数
 * @constructor
 */
function BindGoLogin() {
    document.querySelector('#index_goLogin').onclick = function () {
        window.location = "../../html/index.html"
    }

}

/**
 * 绑定返回页面顶端实现函数
 */
function BindgoTop() {
    document.querySelector('#goTo_btn').onclick = function () {
        $('html, body').animate({scrollTop: 0}, 1000);
    }

}

/**
 * 监听滚轮位置
 * @param getTopHeight1
 */
function addEventListenerNav(getTopHeight1) {
    var getTopHeight = document.querySelector('#index_top_all').getBoundingClientRect().top
    var index_top = document.querySelector('#index_top')
    var index_content_right = document.querySelector('#index_content_right')
    var index_top_sear = document.querySelector('#index_top_sear')
    // document.body.scrollTop=document.documentElement.scrollTop=0
    // 监听事件
    window.addEventListener('scroll', function () {
        let scrollHeight = $('body, html').scrollTop();   // 目前监听的是整个body的滚动条距离
        if (scrollHeight >= getTopHeight1) {
            index_top.className = "index_top index_top1"
            index_content_right.className = "index_content_right index_content_right1"
            index_top_sear.className = "index_top_sear index_top_sear1"
        } else if (scrollHeight < getTopHeight1) {
            index_top.className = "index_top"
            index_content_right.className = "index_content_right"
            index_top_sear.className = "index_top_sear "
        }
    })
}


/**
 * 绑定导航栏搜索变化点击事件
 * */
function BindsearChangeOnckike() {
    let index_top = document.querySelector('#index_top')
    let index_top_sear = document.querySelector('#index_top_sear')
    let index_top_nav_ul_ser = document.querySelector('#index_top_nav_ul_ser')
    let sear_i = document.querySelector('#sear_i')

    index_top_nav_ul_ser.onclick = function () {
        index_top.style.display = "none";
        index_top_sear.style.display = ""

    }
    sear_i.onclick = function () {
        index_top.style.display = "";
        index_top_sear.style.display = "none"
    }

}
